-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add resource not found exception #222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Currently, generating |
|
I suggest adding checks before generation:
|
We’ve discussed this question — it’s not relevant for now. |
|
@artengin please resolve conflicts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors exception handling by introducing a new ResourceNotExistsException to replace ClassNotExistsException across multiple generators. The changes standardize error messages and introduce an abstract base exception class for resource-related exceptions.
- Introduced
AbstractResourceExceptionandResourceNotExistsExceptionto replaceClassNotExistsException - Standardized error messages across all generators to follow a consistent format
- Refactored
ResourceAlreadyExistsExceptionto extend the new abstract base class - Added a helper method
checkResourceNotExists()inEntityGeneratorto consolidate duplicate validation logic
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Exceptions/AbstractResourceException.php | New abstract base class providing common getEntity() method for resource exceptions |
| src/Exceptions/ResourceNotExistsException.php | New exception class for missing resources with standardized error message format |
| src/Exceptions/ResourceAlreadyExistsException.php | Refactored to extend AbstractResourceException and use inherited getEntity() method |
| src/Generators/EntityGenerator.php | Added checkResourceNotExists() helper method and imports for new exception |
| src/Generators/ServiceGenerator.php | Replaced manual validation logic with checkResourceNotExists() call |
| src/Generators/RepositoryGenerator.php | Replaced manual validation logic with checkResourceNotExists() call |
| src/Generators/NovaResourceGenerator.php | Replaced manual validation logic with checkResourceNotExists() call and added missing import |
| src/Generators/ModelGenerator.php | Replaced manual validation logic with checkResourceNotExists() call |
| src/Generators/FactoryGenerator.php | Replaced manual validation logic with checkResourceNotExists() call |
| src/Generators/ControllerGenerator.php | Replaced manual validation logic with checkResourceNotExists() call |
| tests/ServiceGeneratorTest.php | Updated test to expect ResourceNotExistsException with new error message |
| tests/RepositoryGeneratorTest.php | Updated test to expect ResourceNotExistsException with new error message |
| tests/NovaResourceGeneratorTest.php | Updated test to expect ResourceNotExistsException with new error message |
| tests/ModelGeneratorTest.php | Updated test to expect ResourceNotExistsException with new error message |
| tests/FactoryGeneratorTest.php | Updated test to expect ResourceNotExistsException with new error message |
| tests/ControllerGeneratorTest.php | Updated test to expect ResourceNotExistsException with new error message |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| use RonasIT\Support\DTO\RelationsDTO; | ||
| use RonasIT\Support\Events\WarningEvent; | ||
| use Illuminate\Database\Eloquent\Relations\BelongsTo; | ||
| use RonasIT\Support\Exceptions\ClassNotExistsException; |
Copilot
AI
Nov 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The import for ClassNotExistsException is still present but is only used in the getBelongsToModels() method (line 219). Consider whether this method should also be refactored to use ResourceNotExistsException for consistency with the rest of the codebase.










Refs: #179